<template>
  <table class="table">
    <tr>
      <th>ID</th>
      <th>商品名称</th>
      <th>商品价格</th>
    </tr>
    <tr v-for="item in cartItems" :key="item.id">
      <td>{{item.id}}</td>
      <td>{{item.name}}</td>
      <td>{{item.price}}</td>
    </tr>
  </table>
</template>

<script>
  export default {
    data() {
      return {
        cartItems: []
      }
    },
    mounted() {
      const carts = localStorage.getItem("carts");
      this.cartItems = JSON.parse(carts);
    }
  }
</script>

<style>
</style>
